<?php
namespace Home\Controller;

class RedeemController extends \Home\Controller\BaseController
{
	/**
	 * 赎回
	 * @author 刘新
	 */
	public function redeem()
	{
		$param = I('params');
		$data['invest_id'] = I('data.invest_id', '', '/^[1-9]\d*$/', $param);
		$data['count'] = I('data.count', '', '/^\d+$/', $param);
		$data['user_id'] = $this->user['userId'];
		$res = D('Redeem')->addRedeem($data);
		$this->ajaxReturn($res);
	}
	
	/**
	 * 赎回时查询是否违约及违约金
	 */
	public function isDefaults()
	{
		$param = I('params');
		$investId = I('data.invest_id', '', '/^[1-9]\d*$/', $param);
		$count = I('data.count', '', '/^\d+$/', $param);
		$res = D('Invest')->defaultsInfo($count, $investId);
		$this->ajaxReturn($res);
	}
}